This document was compiled on date 2022-07-05 06:04:51 by Pamela Solano for the project: Trace element and phenol composition relationship with oil

1 Oil composition

#rm(list = ls())
require(dplyr)
require(ggplot2)
require(tidyr)
require(stringr)

setwd("G:/My Drive/Studying - Research/Metais-Olive-Oil-Grape/Text-Code")
#setwd("G:/o meu disco/Studying - Research/Metais-Olive-Oil-Grape/Text-Code")

load("oil.rda")

composi <- c("TPhe",    "OrtD", "Flav")

Data <- (data[composi])/apply(data[composi],1,sum)

2 Oil Compositional representations

2.1 GGtern PLOTLY: Oil Compositional representations

require(plotly)

# reusable function for creating annotation object
label <- function(txt) {
  list(
    text = txt, 
    x = 0.1, y = 1,
    ax = 0, ay = 0,
    xref = "paper", yref = "paper", 
    align = "center",
    font = list(family = "serif", size = 15, color = "white"),
    bgcolor = "#b3b3b3", bordercolor = "black", borderwidth = 2
  )
}

# reusable function for axis formatting
axis <- function(txt) {
  list(
    title = txt, tickformat = ".0%", tickfont = list(size = 10)
  )
}

ternaryAxes <- list(
  aaxis = axis("TPhe"), 
  baxis = axis("OrtD"), 
  caxis = axis("Flav")
)

# Initiating a plotly visualization 
p <- plot_ly(
  Data, 
  a = ~TPhe, 
  b = ~OrtD, 
  c = ~Flav, 
  color = I("black"), 
  type = "scatterternary"
) %>%
  layout(
    annotations = label("Ternary Markers"), 
    ternary = ternaryAxes
  )

# htmlwidgets::saveWidget(as_widget(p), "G:/My Drive/Studying - Research/Metais-Olive-Oil-Grape/Text-Code/ggploty-oil.html")

p

3 Correlations: Oil composition vs Elements - scaled